package skill

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	var b = client.Load("SkillPassive")
	if err := json.Unmarshal(b, &PassiveSkillConfigs); err != nil {
		panic(err)
	}

	log.Info("Load SkillPassive.json success.")

}

type (
	PassiveSkillConfig struct {
		SkillID       int32 `json:"ID"` // 技能ID
		Quality       int32 // 技能品质
		MaxLevel      int32 `json:"GradeMax"` // 最大等级
		AttributeType int32 // 属性类型
		AttributeID   int32 // 属性ID
	}
)

var (
	PassiveSkillConfigs = map[int32]PassiveSkillConfig{}
)

func GetByPassiveSkillID(ID int32) (PassiveSkillConfig, error) {

	var conf, ok = PassiveSkillConfigs[ID]
	if ok {
		return conf, nil
	}

	return PassiveSkillConfig{}, errors.New(fmt.Sprintf("GetByPassiveSkillID not found [%d]", ID))
}
